package ogb;

import static org.junit.Assert.assertTrue;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.testing.RobotTestBed;

/**
 * Tests that DeaconBlues is capable of defeating the SpinBot sample robot.
 * Based on sample code from http://code.google.com/p/robocode-pmj-dacruzer/
 * 
 * @author Branden Ogata
 *
 */

public class TestDeaconBluesVersusSpinBot extends RobotTestBed {

  /**
   * Specifies that SpinBot and DeaconBlues are the ones involved in this match.
   * 
   * @return  The comma-delimited list of robots involved in the match.
   * 
   */
  
  @Override
  public String getRobotNames() {
    return "sample.SpinBot,ogb.DeaconBlues";
  }
  
  /**
   * Run eight test rounds.
   * 
   * @return  The number of rounds in the match.
   */
  @Override
  public int getNumRounds() {
    return 8;
  }
  
  /**
   * Asserts that DeaconBlues has won most of the rounds against SpinBot.
   *    
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    BattleResults[] deaconBluesResults = event.getIndexedResults();
    // Assert that DeaconBlues won at least 75 percent of the rounds
    assertTrue("Check DeaconBlues wins", 
                (3 * getNumRounds() / 4) < deaconBluesResults[1].getFirsts());
  }
  
}
